#include<bits/stdc++.h>
#define N 100005
using namespace std;
int T,n,m,L,V,d[N],v[N],a[N],crs[N],p[N],fy[1000005];
struct node{
    int l,r;
}s[N];
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    ios::sync_with_stdio(0);
    cin>>T;
    while(T--){
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++){
            cin>>d[i]>>v[i]>>a[i];
            if(a[i]==0) crs[i]=(v[i]>V);
            long double dis=(1.0*V*V-1.0*v[i]*v[i])/2.0/a[i];
            int pos;
            if(dis<0){
                pos=d[i];
                crs[i]=d[i];
                continue;
            }
            int tmp=dis;
            if(dis==tmp&&a[i]<0);
            else tmp++;
            pos=tmp+d[i];
            crs[i]=pos;
        }
        for(int i=1;i<=m;i++) cin>>p[i];
        int cnt=0;
        for(int i=1;i<=n;i++){
            if(a[i]==0){
                if(v[i]<=V) continue;
                if(d[i]>p[m]) continue;
                cnt++;
                s[cnt].l=lower_bound(p+1,p+m+1,d[i])-p;
                s[cnt].r=m;
            }
            else if(a[i]>0){
                if(crs[i]>p[m]) continue;
                cnt++;
                s[cnt].l=lower_bound(p+1,p+m+1,crs[i])-p;
                s[cnt].r=m;
            }
            else{
                if(crs[i]>p[m]){
                    if(d[i]>p[m]) continue;
                    cnt++;
                    s[cnt].l=lower_bound(p+1,p+m+1,d[i])-p;
                    s[cnt].r=m;
                    continue;
                }
                if(crs[i]<=p[1]) continue;
                cnt++;
                s[cnt].l=lower_bound(p+1,p+m+1,d[i])-p;
                s[cnt].r=lower_bound(p+1,p+m+1,crs[i])-p-1;
            }
            if(s[cnt].l>s[cnt].r) cnt--;
            // cout<<"Get "<<i<<' '<<crs[i]<<endl;
            // cout<<s[cnt].l<<' '<<s[cnt].r<<endl;
        }
        sort(s+1,s+cnt+1,[](node a,node b){
            if(a.r==b.r) return a.l<b.l;
            return a.r<b.r;
        });
        cout<<cnt<<' ';
        int tot=0,lst=-1;
        for(int i=1;i<=cnt;i++){
            if(lst>=s[i].l&&lst<=s[i].r) continue;
            lst=s[i].r;
            tot++;
        }
        cout<<m-tot<<'\n';
    }
    return 0;
}

// 15:29 Problem 'Detect' passed all examples. 100+100+0+0=200